<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title></title>
    <script src="/scripts/jquery.js"></script>
    <link href="/styles/common.css" rel="stylesheet" type="text/css"/>
	
	<style>
		.line_div{
			float:left ;
			width:200px;
			padding:5px 0 0 0;
			height:25px;
		}
		.tit_word{
			padding:30px 0 0 0;
		}
		.list_r{
			padding:0 0 0 10px;
			float:left;
			width:1100px;
		}
		.one_list{
			padding-left:200px;
			clear:both;
		}
		.one_list div{
			border:1px solid #CCCCCC;
			text-align:center;
		}
		.one_list a{
			margin:0 10px 0 0;
			text-decoration: none;
			color:#000000;
		}
		.roleMan_top{
			padding:5px 0 0 210px;
			float:left;
			width:1000px;
			height:25px
		}
	</style>

  </head>
  
  <body>
   	<div class="roleMan_top">
   		<a href="/roleMan/barList.action">添加新角色</a>
   	</div>
   	
   	<div class="list_r">
   		<div class="one_list"><div class="line_div">id</div><div class="line_div">角色名</div><div class="line_div">操作</div></div>
   		<c:forEach var="role" items="${roleList}">
   			<div class="one_list">
	   			<div class="line_div"><c:out value="${role.id}" /></div>
	   			<div class="line_div"><c:out value="${role.roleName}" /></div>
	   			<div class="line_div"><a href="/roleMan/barList.action?roleId=<c:out value="${role.id}" />" class="editRole">编辑</a><a href="#" class="delRole">删除</a></div>
   			</div>
   		</c:forEach>
   	</div>
  </body>
</html>
<script>
	$(document).ready(function(){
		$(".delRole").click(function(){
			delRole($(this).parent().parent());
			return false ;
		});
	});
	function delRole(line_dom){
		var id = $(line_dom).find("div").eq(0).text();
		if(id != 1){
			$.ajax({
				dataType:"json",
				type:"POST",
				url:"/ajaxcreaterole/delRole.action",
				data:{
					"roId":id,
				},
				success:function(msg){
					var data = eval("("+msg+")");
					if(data.status){
						$(line_dom).slideUp(function(){
							$(this).remove();
						});
					}else{
						alert(data.message);
					}
				},
			});
		}else{
			alert("这个不允许删除");
		}
		
		
	}
</script>
